def ip_addr(req):
    if req.META.get('HTTP_X_FORWARDED_FOR'):
        ip = req.META.get("HTTP_X_FORWARDED_FOR")
    else:
        ip = req.META.get("REMOTE_ADDR")
    return ip
